home *** CD-ROM | disk | FTP | other *** search
/ NASA Climatology Interdisciplinary Data Collection / NASA Climatology Interdisciplinary Data Collection - Disc 4.iso / software / grads / lib / ncep.gui < prev    next >
Encoding:
Text File  |  1998-04-23  |  16.2 KB  |  355 lines

  1. #  ncep.gui - last revision: October 12, 1997
  2. #
  3. #  Sample widget script for the NCEP/NCAR Re-analysis CDROM. 
  4. #  Modify the first line ("chdir") for the location of your CDROM drive.
  5. #
  6. #  How to invoke this script:
  7. #
  8. #  At startup. Set the enviroment variable GAGUI with the
  9. #  name of the script file, e.g., 
  10. #
  11. #  % setenv GAGUI ncep.gui
  12. #
  13. #  At the GrADS command line prompt. Simply type
  14. #
  15. #  ga> gui ncep.gui
  16. #
  17. #  Of course, you must have a version of GrADS built with
  18. #  Athena Widgets support.
  19. #
  20. #  --
  21. #   (c) 1997 by Arlindo da Silva
  22. #
  23. #   Permission is granted to any individual or institution to use,
  24. #   copy, or redistribute this software so long as it is not sold for
  25. #   profit, and provided this notice is retained. 
  26. #
  27. #  See also sample.gui, sample2.gui.
  28. #.........................................................................
  29.  
  30.  
  31. #  Mofify this for the location of your CDROM
  32. #  Win32 Users: Use //d to indicate drive d:
  33. #  ------------------------------------------
  34.    chdir("//d/")    
  35.    
  36.  
  37. #  Most "exec" commands are supported
  38. #  ----------------------------------
  39.    reinit
  40.    set gxout shaded
  41.  
  42.    
  43. # A "label" is an inactive widget which display some text, 
  44. # e.g., an informative  title. The first argument, "root"
  45. # in this case, is the name you give to the widget so that
  46. # you can refer to it later on
  47. # -------------------------------------------------------
  48.   MakeLabel(root,"NCEP/NCAR Re-analysis CDROM")
  49.  
  50. # This command creates a dropdown menu called " File "
  51. # as usual, the first argument "file" is the name of the
  52. # widget
  53. # -------------------------------------------------------
  54.   MakeMenu ( file, " File " )
  55.  
  56.  
  57. # Once you make a memu, you create its items. For the first item:
  58. # --------------------------------------------------------------
  59.       MakeMenuItem(open,  file, "Open",             Load,    "open")
  60.  
  61. # The parameters this particular item are:
  62. #     open    the name of the item widget
  63. #     file    the menu the item belongs to (see MakeMenu above)
  64. #     "Open"  This is the text it displays on the screen
  65. #     Load    this is the callback name, i.e., the widget invokes
  66. #             this function when pressed. This particular callback
  67. #             pops up a "file finder" widget, and after the user
  68. #             clicks on a file name it executes the grads command
  69. #             "open" (see last argument) on this file. A list
  70. #             of the other available callbacks can be found in the
  71. #             end of this file.
  72. #     "open"  Argument to be passed to the callback. In this 
  73. #             particular case, it is the GrADS command to be
  74. #             executed on the file.
  75. #  The definition of the other items in this menu follows.
  76.       MakeMenuItem(sdf,   file, "SDF Open",         Load,    "sdfopen")
  77.       MakeMenuItem(xdf,   file, "XDF Open",         Load,    "xdfopen")
  78.       MakeMenuItem(fsel,  file, "File Selection ",  FileSel, NULL )
  79.       MakeMenuItem(browse,file, "View Text File",   Browse,  NULL)
  80.       MakeMenuItem(junk,  file, "_______________",  NULL,    NULL )
  81.       MakeMenuItem(exec,  file, "Exec",             Load,    "exec")
  82.       MakeMenuItem(run,   file, "Run",              Load,    "run")
  83.       MakeMenuItem(gui,   file, "GUI",              Load,    "gui")
  84.       MakeMenuItem(junk,  file, "_______________",  NULL,    NULL )
  85.       MakeMenuItem(fresh, file, "Refresh",          Cmd,     "  ")
  86.       MakeMenuItem(init,  file, "Reinit",           Cmd,     "reinit")
  87.       MakeMenuItem(exit,  file, "Exit",             Cmd,     "quit")
  88.  
  89.  
  90. # A menu for gx metafile printing related commands
  91. # ------------------------------------------------
  92.   MakeMenu ( print, " Print " )
  93.       MakeMenuItem(printit, print, "Print",         Cmd,   "print")
  94.       MakeMenuItem(enable,  print, "Enable  Print", Load,  "enable print")
  95.       MakeMenuItem(disable, print, "Disable Print", Cmd,   "disable print")
  96.  
  97. # A menu with assorted internal options
  98. # -------------------------------------
  99.   MakeMenu ( options, " Options " )
  100.       MakeMenuItem(shade,  options, "Shaded",      Cmd, "set gxout shaded" )
  101.       MakeMenuItem(cont,   options, "Contour",     Cmd, "set gxout contour" )
  102.       MakeMenuItem(grfill, options, "Grid Fill",   Cmd, "set gxout grfill" )
  103.       MakeMenuItem(grvals, options, "Grid Values", Cmd, "set gxout grid" )
  104.       MakeMenuItem(vec,    options, "Vector",      Cmd, "set gxout vector" )
  105.       MakeMenuItem(strm,   options, "Streamlines", Cmd, "set gxout stream" )
  106.       MakeMenuItem(bar,    options, "Bar Chart",   Cmd, "set gxout bar" )
  107.       MakeMenuItem(line,   options, "Line Plot",   Cmd, "set gxout line" )
  108.       MakeMenuItem(barb,   options, "Wind Barbs",  Cmd, "set gxout  barb" )
  109.       MakeMenuItem(junk,   options, "_______________",  NULL, NULL )
  110.       MakeMenuItem(ci,     options, "Contour Interval",  CmdStr, "set cint" )
  111.       MakeMenuItem(tit,    options, "Draw Title", CmdStr, "draw title " )
  112.       MakeMenuItem(cbar,   options, "Color Bar",  Cmd, "run cbarn" )
  113.  
  114.  
  115. # Creates simple buttons. Buttons work pretty much like menu items
  116. # but they do not belong to any menu and are directly clickable.
  117. # ------------------------------------------------------------------
  118.   MakeButton( clear,  "Clear",      Cmd,      "clear" )
  119.   MakeButton( quit,   "Quit",       Cmd,      "quit" )
  120.   MakeButton( prompt, " ga> ",  CmdWin,  NULL )
  121.   MakeButton( rein, "Reinit", Cmd,     "reinit")
  122.  
  123. # A menu for defining GrADS dimensions. This is very crude right now.
  124. # I will be developing a specific callback with rubber bands
  125. # etc. for these functions. Stay tuned. 
  126. # ------------------------------------------------------------------
  127.   MakeMenu( dim, "Dim")
  128.       MakeMenuItem(lat,  dim, "Latitude",  CmdStr, "set lat " )
  129.       MakeMenuItem(lon,  dim, "Longitude", CmdStr, "set lon " )
  130.       MakeMenuItem(lev,  dim, "Level",     CmdStr, "set lev " )
  131.       MakeMenuItem(time, dim, "Time",      CmdStr, "set time " )
  132.       MakeMenuItem(junk, dim, "_________", NULL,   NULL )
  133.       MakeMenuItem(x,    dim, "x",         CmdStr, "set x " )
  134.       MakeMenuItem(y,    dim, "y",         CmdStr, "set y " )
  135.       MakeMenuItem(z,    dim, "z",         CmdStr, "set z " )
  136.       MakeMenuItem(t,    dim, "t",         CmdStr, "set t " )
  137.  
  138. # Frequently used buttons (and toggle)
  139. # -----------------------------------
  140.   MakeButton( var,  "Var",    VarSel,  NULL )
  141.   MakeToggle( hold, "Hold",   FALSE,  NULL, Toggle,  "hold" )
  142.   MakeButton( prev, " << ",   Display, "<<" )
  143.   MakeButton( play, "Display",   Display, "DISPLAY" )
  144.   MakeButton( next, " >> ",   Display, ">>" )
  145.  
  146.  
  147. # CDROM specific menu's
  148. # ---------------------
  149.   MakeMenu(cc, "Climate")
  150.       MakeMenuItem(c1, cc, "Z u v T q ...", Open, "open climate/prflcl" )
  151.       MakeMenuItem(c2, cc, "Heat Fluxes", Open, "open climate/heatcl" )
  152.       MakeMenuItem(c3, cc, "Potential Vorticity", Open, "open climate/ipvcl" )
  153.  
  154.   MakeMenu(mm, "Monthly")
  155.       MakeMenuItem(m1, mm, "Z u v T q ...",  Open, "open monthly/prfl" )
  156.       MakeMenuItem(m2, mm, "Potential Vorticity",  Open, "open monthly/ipv" )
  157.  
  158.   MakeMenu(hd, "Z")
  159.       MakeMenuItem(xxx, hd, "  Daily",  NULL, NULL )
  160.       MakeMenuItem(xxx, hd, "_________",  NULL, NULL )
  161.       MakeMenuItem(hd5, hd, "Z  30 hPa", Open, "open daily/z30" )
  162.       MakeMenuItem(hd4, hd, "Z 200 hPa", Open, "open daily/z200" )
  163.       MakeMenuItem(hd3, hd, "Z 500 hPa", Open, "open daily/z500" )
  164.       MakeMenuItem(hd2, hd, "Z 700 hPa", Open, "open daily/z700" )
  165.       MakeMenuItem(hd1, hd, "Z 850 hPa", Open, "open daily/z850" )
  166.  
  167.   MakeMenu(ud, "u")
  168.       MakeMenuItem(xxx, ud, "  Daily",  NULL, NULL )
  169.       MakeMenuItem(xxx, ud, "_________",  NULL, NULL )
  170.       MakeMenuItem(ud5, ud, "U  30 hPa", Open, "open daily/u30" )
  171.       MakeMenuItem(ud4, ud, "U 200 hPa", Open, "open daily/u200" )
  172.       MakeMenuItem(ud3, ud, "U 500 hPa", Open, "open daily/u500" )
  173.       MakeMenuItem(ud2, ud, "U 700 hPa", Open, "open daily/u700" )
  174.       MakeMenuItem(ud1, ud, "U 850 hPa", Open, "open daily/u850" )
  175.  
  176.   MakeMenu(vd, "v")
  177.       MakeMenuItem(xxx, vd, "  Daily",  NULL, NULL )
  178.       MakeMenuItem(xxx, vd, "_________",  NULL, NULL )
  179.       MakeMenuItem(vd5, vd, "V  30 hPa", Open, "open daily/v30" )
  180.       MakeMenuItem(vd4, vd, "V 200 hPa", Open, "open daily/v200" )
  181.       MakeMenuItem(vd3, vd, "V 500 hPa", Open, "open daily/v500" )
  182.       MakeMenuItem(vd2, vd, "V 700 hPa", Open, "open daily/v700" )
  183.       MakeMenuItem(vd1, vd, "V 850 hPa", Open, "open daily/v850" )
  184.  
  185.   MakeMenu(td, "T")
  186.       MakeMenuItem(xxx, td, "  Daily",  NULL, NULL )
  187.       MakeMenuItem(xxx, td, "_________",  NULL, NULL )
  188.       MakeMenuItem(td5, td, "T  30 hPa", Open, "open daily/t30" )
  189.       MakeMenuItem(td4, td, "T 200 hPa", Open, "open daily/t200" )
  190.       MakeMenuItem(td3, td, "T 500 hPa", Open, "open daily/t500" )
  191.       MakeMenuItem(td2, td, "T 700 hPa", Open, "open daily/t700" )
  192.       MakeMenuItem(td1, td, "T 850 hPa", Open, "open daily/t850" )
  193.       MakeMenuItem(td0, td, "T at 2m", Open, "open daily/t2m" )
  194.  
  195.   MakeMenu(qd, "q")
  196.       MakeMenuItem(xxx, qd, "  Daily",  NULL, NULL )
  197.       MakeMenuItem(xxx, qd, "_________",  NULL, NULL )
  198.       MakeMenuItem(qd3, qd, "Q 500 hPa", Open, "open daily/q500" )
  199.       MakeMenuItem(qd2, qd, "Q 700 hPa", Open, "open daily/q700" )
  200.       MakeMenuItem(qd1, qd, "Q 850 hPa", Open, "open daily/q850" )
  201.       MakeMenuItem(qd0, qd, "Q at 2m", Open, "open daily/q2m" )
  202.  
  203.   MakeMenu(sd, "Sfc")
  204.       MakeMenuItem(xxx,  sd, "     Daily",  NULL, NULL )
  205.       MakeMenuItem(xxx,  sd,"__________________",  NULL, NULL )
  206.       MakeMenuItem(sd1,  sd, "Sea Level Pressure",  Open, "open daily/mslp" )
  207.       MakeMenuItem(sd2,  sd, "10 meter u-wind",  Open, "open daily/u10m" )
  208.       MakeMenuItem(sd3,  sd, "10 meter v-wind",  Open, "open daily/v10m" )
  209.       MakeMenuItem(sd4,  sd, "Zonal stress",  Open, "open daily/uflx" )
  210.       MakeMenuItem(sd5,  sd, "Meridional stress", Open, "open daily/vflx" )
  211.       MakeMenuItem(xxx,  sd,"__________________",  NULL, NULL )
  212.       MakeMenuItem(sd6,  sd, "Precipitation",  Open, "open daily/prate" )
  213.       MakeMenuItem(sd7,  sd, "Latent Heat Flux",  Open, "open daily/lhtfl" )
  214.       MakeMenuItem(sd8,  sd, "Sensible Heat Flux",  Open, "open daily/" )
  215.       MakeMenuItem(xxx, sd,"__________________",  NULL, NULL )
  216.       MakeMenuItem(sd9, sd, "Shortwave  [down]",  Open, "open daily/dswrfsfc" )
  217.       MakeMenuItem(sda1, sd, "Longwave  [down]",  Open, "open daily/dlwrfsfc" )
  218.       MakeMenuItem(sda2, sd, "Shortwave [up]",  Open, "open daily/uswrfsfc" )
  219.       MakeMenuItem(sda3, sd, "Longwave  [up]",  Open, "open daily/ulwrfsfc" )
  220.  
  221.   MakeMenu(hh, "Help")
  222.       MakeMenuItem(h1, hh, "About this Software", NULL, NULL )
  223.       MakeMenuItem(h2, hh, "About this CDROM", Browse, "read.ams")
  224.       MakeMenuItem(h3, hh, "BAMS Article", Browse, "paper/bamspapr.asc")
  225.  
  226.  
  227. # Once you define buttons and menus you may want to enforce their
  228. # relative position. The very first button is always placed at the
  229. # upper left corner.
  230. # ----------------------------------------------------------------
  231.  
  232.   # First row 
  233.   SetWidgetPos(file,    PLACE_UNDER, root, NO_CARE,     NULL)
  234.   SetWidgetPos(print,   PLACE_UNDER, root, PLACE_RIGHT, file )
  235.   SetWidgetPos(options, PLACE_UNDER, root, PLACE_RIGHT, print )
  236.   SetWidgetPos(dim,     PLACE_UNDER, root, PLACE_RIGHT, options )
  237.   SetWidgetPos(rein,    PLACE_UNDER, root, PLACE_RIGHT, dim )
  238.   SetWidgetPos(prompt,  PLACE_UNDER, root, PLACE_RIGHT, rein )
  239.  
  240.   # Second row
  241.   SetWidgetPos(cc, PLACE_UNDER, file, NO_CARE,     NULL)
  242.   SetWidgetPos(mm, PLACE_UNDER, file, PLACE_RIGHT, cc)
  243.   SetWidgetPos(hd, PLACE_UNDER, file, PLACE_RIGHT, mm)
  244.   SetWidgetPos(ud, PLACE_UNDER, file, PLACE_RIGHT, hd)
  245.   SetWidgetPos(vd, PLACE_UNDER, file, PLACE_RIGHT, ud)
  246.   SetWidgetPos(td, PLACE_UNDER, file, PLACE_RIGHT, vd)
  247.   SetWidgetPos(qd, PLACE_UNDER, file, PLACE_RIGHT, td)
  248.   SetWidgetPos(sd, PLACE_UNDER, file, PLACE_RIGHT, qd)
  249.   SetWidgetPos(hh, PLACE_UNDER, file, PLACE_RIGHT, sd)
  250.  
  251.   # third row
  252.   SetWidgetPos(hold,  PLACE_UNDER, cc, NO_CARE,     NULL)
  253.   SetWidgetPos(var,   PLACE_UNDER, cc, PLACE_RIGHT, hold )
  254.   SetWidgetPos(prev,  PLACE_UNDER, cc, PLACE_RIGHT, var )
  255.   SetWidgetPos(play,  PLACE_UNDER, cc, PLACE_RIGHT, prev )
  256.   SetWidgetPos(next,  PLACE_UNDER, cc, PLACE_RIGHT, play )
  257.   SetWidgetPos(clear, PLACE_UNDER, cc, PLACE_RIGHT, next )
  258.   SetWidgetPos(quit,  PLACE_UNDER, cc, PLACE_RIGHT, clear )
  259.  
  260.  
  261. # You can optionally select a font for ALL widgets
  262. # ------------------------------------------------
  263. # GetFont(font,"-*-helvetica-bold-o-normal--*-*-*-*-*-*-*-*" )
  264.   GetFont(font,"-*-helvetica-bold-o-normal--12-*-*-*-*-*-*-*" )
  265.   AllWidgetFont(font)
  266.  
  267.   GetFont(font,"-*-helvetica-bold-o-normal--14-*-*-*-*-*-*-*" )
  268.   SetWidgetFont(root,myfont)
  269.  
  270.  
  271. # In order to make your widgets appear on the screen you *must*
  272. # issue this command.
  273. # -------------------------------------------------------------
  274.   ShowDisplay()
  275.   
  276.  
  277. # After your widgets appear on the screen, you can set the color 
  278. # of your widgets. The following colors are pre-defined:
  279. # white, back, red, green, blue, yellow.
  280. # --------------------------------------------------------------
  281.   GetNamedColor(gray,"grey")
  282.   GetNamedColor(Blue,"LightSkyBlue")
  283.   GetNamedColor(pink,"gold")         # pink is actually gold, get it?
  284.   AllFgColor(black)
  285.   AllBgColor(Blue)
  286.   SetBgColor(root,white)
  287.   SetFgColor(root,red)
  288.   SetFgColor(prompt,yellow)
  289.   SetBgColor(prompt,red)
  290.   SetBgColor(prev,pink)
  291.   SetBgColor(play,pink)
  292.   SetBgColor(next,pink)
  293.   SetBgColor(hold,gray)
  294.   SetBgColor(var,gray)
  295.   SetBgColor(clear,gray)
  296.   SetBgColor(rein,gray)
  297.   SetBgColor(quit,gray)
  298.  
  299.  
  300. # And you must call this function at the end of your first GUI script.
  301. # This instructs the X Toolkit to enter an infinite loop, monitoring
  302. # keyboard and mouse events. Repeating: you *must* call MainLoop().
  303. # -------------------------------------------------------------------
  304.   MainLoop()
  305.  
  306. #........................................................................
  307. #
  308. # APPENDIX: Currently available callback functions
  309. #
  310. #     Browse    Opens a text file, such as a help file, on a separate
  311. #               window.
  312. #     Cmd       Executes a generic GrADS command
  313. #     CmdStr    Like Cmd, but the user is prompted for an additional
  314. #               string to be appended to the GrADS command.
  315. #     CmdWin    Invokes a window for GrADS command line interface.
  316. #               User can click on past commands from a list.
  317. #     CmdLine   Invokes the standard GrADS command line interface.
  318. #               When the command line is active the other widgets
  319. #               are not available (may be fixed in the future).
  320. #     Display   A generic callback for displaying the current variable
  321. #               (or expression) set with VarSel. The options are:
  322. #                  <<    decrements time and executes display
  323. #                 PLAY   starts animation from current to last time
  324. #                DISPLAY just executes display
  325. #                  >>    increments time and  executes display
  326. #               If the "hold" toggle state is OFF (the default),
  327. #               the screen is cleared before displaying.
  328. #     Edit      Like browse, but the user can edit the file. This simple
  329. #               text editor is integrated with GrADS, providing a very
  330. #               elementary Integrated Development Enviroment (IDE) for
  331. #               GrADS scripts. In particular, the script being edited
  332. #               can be executed by clicking on a button (not
  333. #               implemented yet).
  334. #     FileSel   Pops up a scrollable list and asks the user to selected
  335. #               a file among the currently opened GrADS files (including
  336. #               SDFs). The selected file becomes the default.
  337. #     Load      Pops up a "file finder" widget, and after the user
  338. #               clicks on a file name it executes a GrADS command
  339. #               specified as the last argument. In case of "open" or 
  340. #               "sdfopen" the files becomes the default, and the
  341. #               user is asked to select a variable from this file.
  342. #     Open      Similar to Load, but the file name must be specified.
  343. #     Toggle    Turn internal options ON/OFF. The only internal
  344. #               option currently supported is "hold". This callback is
  345. #               usually used with MakeToggle(), see example above.
  346. #     VarSel    Pops up a scrollable list and asks the user to selected
  347. #               a variable from the default file. The user can also
  348. #               type a generic GrADS expression instead of selecting
  349. #               a single variable.
  350. #     NULL      Does not do anything, used for inactive buttons.
  351. #
  352. #........................................................................
  353.  
  354.  
  355.